package com.ocean.admin.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ocean.admin.entity.SysRoleMenu;
import com.ocean.admin.mapper.SysRoleMenuMapper;
import com.ocean.admin.service.ISysRoleMenuService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 角色和菜单关联表 服务实现类
 * </p>
 *
 * @author zhang
 * @since 2022-08-16
 */
@Service
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements ISysRoleMenuService {

    /**
     * 查询菜单是否被分配角色
     *
     * @param menuId 菜单ID
     * @return 结果
     */
    @Override
    public Boolean checkMenuExistRole(Long menuId) {
        return baseMapper.selectCount(Wrappers.<SysRoleMenu>lambdaQuery()
                .eq(SysRoleMenu::getMenuId, menuId)) > 0;
    }
}
